{{- define "prometheus.nsf" }}
{{- if .Values.enable_prometheus_nsf -}}
    - job_name: nsf
      honor_labels: true
      metrics_path: /prom/metric
      scheme: http
      static_configs:
      - targets:
        - nsf-server.{{ .Values.nsf_namespace }}.svc.{{ .Values.cluster_dns_domain }}
        labels:
          env_id: {{ .Values.nsf_environment }}
          job: nsf
    - job_name: nsf-turbine
      honor_labels: true
      metrics_path: /metric
      scheme: http
      static_configs:
      - targets:
        - nsf-turbine.{{ .Values.nsf_namespace }}.svc.{{ .Values.cluster_dns_domain }}:8001
        labels:
          env_id: {{ .Values.nsf_environment }}
          job: nsf
    - job_name: nsf-etcd
      honor_labels: true
      scrape_interval: 1m
      scrape_timeout: 10s
      metrics_path: /metrics
      scheme: http
      kubernetes_sd_configs:
      - role: pod
      relabel_configs:
      - source_labels: [__meta_kubernetes_pod_name]
        separator: ;
        regex: (.*)
        target_label: pod_name
        replacement: $1
        action: replace
      - source_labels: [__meta_kubernetes_pod_name]
        separator: ;
        regex: etcd-nsf(.*)
        replacement: $1
        action: keep
      - source_labels: [__address__]
        separator: ;
        regex: (.*)
        target_label: __address__
        replacement: ${1}:6379
        action: replace
      - source_labels: [__meta_kubernetes_pod_name]
        separator: ;
        regex: (.*)
        target_label: pod
        replacement: ${1}
        action: replace
{{- end -}}
{{- end }}
{{- define "prometheus.apigw" }}
{{- if .Values.enable_prometheus_apigw -}}
    - job_name: 'apigw-statsd'
      honor_labels: true
      scrape_interval: 30s
      metrics_path: /metrics
      scheme: http
      kubernetes_sd_configs:
      - role: pod
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace]
        separator: ;
        regex: {{ .Values.apigw_namespace }}
        replacement: $1
        action: keep
      - source_labels: [__meta_kubernetes_pod_label_gw_cluster]
        separator: ;
        regex: (.+)
        replacement: $1
        action: keep
      - source_labels: [__meta_kubernetes_pod_container_port_name]
        separator: ;
        regex: stats
        action: keep
      - source_labels: [__meta_kubernetes_pod_label_gw_cluster]
        target_label: cluster_name
      - source_labels: [__meta_kubernetes_pod_name]
        target_label: instance_name
{{- end -}}
{{- end }}
{{- define "prometheus.kube-state-metrics" }}
{{- if .Values.enable_kube_state_metrics -}}
    - job_name: kube-metric-server
      honor_labels: true
      scrape_interval: 1m
      scrape_timeout: 30s
      metrics_path: /metrics
      scheme: http
      kubernetes_sd_configs:
      - role: pod
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace]
        separator: ;
        regex: kube-system
        replacement: $1
        action: keep
      - source_labels: [__meta_kubernetes_pod_label_part]
        separator: ;
        regex: kube-state-metrics
        replacement: $1
        action: keep
      - source_labels: [__address__]
        separator: ;
        regex: (.*)
        target_label: __address__
        replacement: ${1}:10260
        action: replace
{{- end -}}
{{- end }}
